import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';

class Util {
  // 显示toast
  static showToast({required String msg}) {
    Fluttertoast.showToast(
        msg: msg,
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 2,
        backgroundColor: Colors.black.withAlpha(50),
        textColor: Colors.white,
        fontSize: 14.sp);
  }
  
  // 时间戳格式化（13位）
  static String formatTimestamp(
      {required int timestamp, String pattern = 'yyyy-MM-dd HH:mm:ss'}) {
    return DateFormat(pattern).format(
      DateTime.fromMillisecondsSinceEpoch(timestamp),
    );
  }
}
